{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c4ba8e69-ceee-4e3f-8a95-6a7cf0aa7b29",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "要下雨了，快做好准备吧\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from sklearn.naive_bayes import BernoulliNB \n",
    "x = np.array([\n",
    "    [0, 1, 0],\n",
    "    [1, 1, 1],\n",
    "    [0, 1, 1],\n",
    "    [0, 0, 0],\n",
    "    [0, 1, 1],\n",
    "    [0, 1, 0],\n",
    "    [1, 0, 0]\n",
    "])\n",
    "y = np.array([0, 1, 1, 0, 1, 0, 0])\n",
    "model = BernoulliNB() \n",
    "model.fit(x, y)      \n",
    "test_data = np.array([[1, 0, 1]])\n",
    "result = model.predict(test_data)\n",
    "if result == 0:\n",
    "    print(\"这是一个好天气\")\n",
    "else:\n",
    "    print(\"要下雨了，快做好准备吧\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
